Home:ALL Converter>I can't connect to mongodb with the readPreference option

I can't connect to mongodb with the readPreference option

Ask Time:2019-12-07T01:08:25         Author:Leonard Jusa Ockonell

Json Formatter

I am making an app in nodejs and mongodb and i'm trying to connect to mongodb with the following options:

let ReadPreference = {
PRIMARY: 'PRIMARY',
PRIMARY_PREFERRED: 'PRIMARY_PREFERRED',
SECONDARY: 'secundary', // in upper or lower case gives the same error
SECONDARY_PREFERRED: 'SECONDARY_PREFERRED',
NEAREST: 'NEAREST'
};

let OPTIONS = {
     poolSize: 10,
     replicaSet: 'rs0', readPreference
     readPreference: ReadPreference.SECONDARY
};

but I get the following error:

TypeError: Invalid read preference mode secundary.

I don't know why he throws that error at me, can you help me solve it?

code:

function connection_secondary(){
    return new Promise( (resolve,reject)=>{
        mongoCliR.connect('mongodb://ANY_IP:27017,ANY_IP:27017', OPTIONS,(err, db)=>{
            if(err){
                reject(err);
            }else{
                resolve(db.db('SINCO'));
            }
        });
    })
}

Author:Leonard Jusa Ockonell,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/59217514/i-cant-connect-to-mongodb-with-the-readpreference-option
yy